package persi.hibernate.transactionStatus;

import org.hibernate.Transaction;

import persi.hibernate.HibernateUtils;

public class TransactionBeginStatus extends TransactionStatus {

	@Override
	public void commit(final Transaction tx) {
		tx.commit();
		killTransaction();
	}

	private void killTransaction() {
		HibernateUtils.getLocalTransaction().set(null);
		HibernateUtils.getStatus().set(new TransactionNotCreatedStatus());
	}

	@Override
	public void rollback(final Transaction tx) {
		tx.rollback();
		killTransaction();
	}

}
